import { QueryformModuleType } from '/#/store'
import { isJson } from '@/utils/validate'
const isStreet = JSON.parse(localStorage.getItem('info'))?.isStreet || ''

let checkList = [
    '工单编号',
    '提示信息',
    '锁单人',
    '派单类型',
    '工单性质',
    '工单状态',
    '工单标题',
    '工单内容',
    '主办部门',
    '主办部门工单状态',
    '从办部门',
    '从办部门工单状态',
    '回访时间',
    '回访次数',
    '回访备注',
    '承办单位',
    // '剔除状态',
    // '挂账状态',
    '来电人',
    '来电号码',
    '来电次数',
    '来电主体',
    '问题分类',
    '标签',
    '派单时间',
    '处理时限',
    '截止时间',
    '所属辖区',
    '接单部门',
    '七有五性',
    '不纳入类型',
    '市回复时间',
    '考核类型',
    '村/社区',
    '小区点位',
    '指派人员',
    '二次回访',
    '系统签收时间',
    // '领导批办',
  ],
  columns = [
    {
      label: '工单编号',
      sortable: true,
      disableCheck: true,
      fixed: 'left',
      width: 190,
    },
    {
      label: '提示信息',
      prop: 'tips',
      align: 'left',
      width: 250,
    },
    {
      label: '锁单人',
      width: 180,
    },
    {
      label: '派单类型',
      width: 80,
    },
    {
      label: '工单性质',
      width: 80,
    },
    {
      label: '工单状态',
      width: 150,
    },
    {
      label: '工单标题',
      prop: 'title',
    },
    {
      label: '工单内容',
      prop: 'majorContent',
    },
    {
      label: '主办部门',
      prop: 'organizerName',
    },
    {
      label: '主办部门工单状态',
    },
    {
      label: '从办部门',
      prop: 'subordinateName',
    },
    {
      label: '从办部门工单状态',
    },
    {
      label: '回访时间',
      prop: 'huifangTime',
      width: 156,
    },
    {
      label: '回访次数',
      width: 100,
    },
    {
      label: '回访备注',
      prop: 'huifangresult',
      width: 156,
    },
    {
      label: '承办单位',
      // prop: 'childOrgNames',
    },
    // {
    //   label: '剔除状态',
    //   width: 100,
    // },
    // {
    //   label: '挂账状态',
    //   width: 100,
    // },
    {
      label: '来电人',
      prop: 'callerName',
      width: 100,
    },
    {
      label: '来电号码',
      prop: 'callerPhone',
      width: 110,
      sortable: true,
    },
    {
      label: '来电次数',
      width: 110,
    },
    {
      label: '来电主体',
      width: 80,
    },
    {
      label: '问题分类',
      width: 300,
    },
    {
      label: '标签',
      prop: 'labelName',
      width: 110,
    },
    {
      label: '派单时间',
      prop: 'dispatchtime',
      width: 156,
    },
    {
      label: '处理时限',
      width: 156,
    },
    {
      label: '截止时间',
      prop: 'deadlinedate',
      width: 156,
    },
    {
      label: '所属辖区',
      prop: 'orgName',
    },
    {
      label: '接单部门',
      prop: 'dwName',
    },
    {
      label: '七有五性',
      prop: 'qiyouName',
      width: 110,
    },
    {
      label: '不纳入类型',
      prop: 'tichuname',
      width: 300,
    },
    // {
    //   label: '市回复时间',
    //   prop: 'replyCityTime',
    //   width: 156,
    // },
    {
      label: '考核类型',
      prop: 'dictValue',
    },
    {
      label: '村/社区',
      prop: 'communityName',
    },
    {
      label: '小区点位',
      prop: 'communityAddress',
    },
    {
      label: '指派人员',
      prop: 'childUserNames',
    },
    {
      label: '二次回访',
      width: 80,
    },
    {
      label: '系统签收时间',
      prop: 'signtime',
    },
    // {
    //   label: '领导批办',
    //   width: 80,
    // },
  ]

columns = columns.map((item, index) => {
  // item.order = index + 1
  return item
})
if (isStreet != 0) {
  checkList.splice(
    checkList.findIndex((item) => item === '锁单人'),
    1
  )
  columns.splice(
    columns.findIndex((item) => item.label === '锁单人'),
    1
  )
}

var finallyColumns = columns.filter((item) => checkList.includes(item.label))

const defaultTheme = {
  stripe: true,
  border: true,
  lineHeight: 'mini',
  checkList: checkList,
  columns: columns,
  finallyColumns: finallyColumns,
}
const getLocalStorage = (key) => {
  const value = localStorage.getItem(key)
  if (isJson(value)) {
    return JSON.parse(value)
  } else {
    return false
  }
}
let token = getLocalStorage('jsjb_Theme_')
export const useQueryformStore = defineStore('queryform', {
  state: (): QueryformModuleType => ({
    admin: false,
    role: [],
    permission: [],
  }),
  getters: {
    getAdmin: (state) => state.admin,
    getRole: (state) => state.role,
    getPermission: (state) => state.permission,
  },
  actions: {
    setFull(admin: boolean) {
      this.admin = admin
    },
    setRole(role: string[]) {
      this.role = role
    },
    setPermission(permission: string[]) {
      this.permission = permission
    },
  },
})
